package defpackage; import com.facebook.ads.AudienceNetworkActivity; import defpackage.ssz; import defpackage.stf; import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; /* renamed from: ssu reason: default package */ public final class ssu { private static String usE = "https://note-api.wps.cn"; private static int usF = 10240; private static suu usj = suu.fgZ(); public static ssv<stg> C(String str, long j) throws sul { String str2 = usE + "/notesvr/get/noteversion"; try { sum a = suj.a(str2, new suk().n("token", str).n("lastRequestTime", Long.valueOf(j))); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, stg.i(SS)); } ssv<stg> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<stb> D(String str, long j) throws sul { String str2 = usE + "/notesvr/get/notegroup"; try { sum a = suj.a(str2, new suk().n("token", str).n("lastRequestTime", Long.valueOf(j))); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, stb.f(SS)); } ssv<stb> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } public static void SB(String str) { if (str.endsWith("/")) { str = str.substring(0, str.length() - 1); } usE = str; } public static ssv<ssx> SC(String str) throws sul { String str2 = usE + "/notesvr/get/security-config"; try { sum a = suj.a(str2, new suk().n("token", str)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { ssx ssx = new ssx(); ssx.usI = SS.optString("accessKeyId"); ssx.usJ = SS.optString("accessKeySecret"); ssx.usK = SS.optString("s3Region"); ssx.usL = SS.optString("s3Bucket"); ssx.usM = SS.optString("aesPassword"); ssx.usM = sua.ag(ssx.usM, "H9n&S@oGohGpV6d7*"); return new ssv<>(a.code, SS, ssx); } ssv<ssx> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<ste> a(String str, String str2, int i, long j, int i2, int i3, String str3) throws sul { String str4 = usE + "/notesvr/set/noteinfo"; try { sum a = suj.a(str4, new suk().n("token", str).n("noteId", str2).n("star", Integer.valueOf(i)).n("remindTime", Long.valueOf(j)).n("remindType", Integer.valueOf(i2)).n("localInfoVersion", Integer.valueOf(i3)).n("groupId", str3)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { ste ste = new ste(); int i4 = SS.getInt("infoVersion"); long j2 = SS.getLong("infoUpdateTime"); ste.usX = i4; ste.usY = j2; return new ssv<>(a.code, SS, ste); } ssv<ste> ssv = new ssv<>(a.code, SS, null); usj.a(str4, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str4, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<stc> a(String str, String str2, String str3, int i) throws sul { String str4 = usE + "/notesvr/set/notegroup"; try { sum a = suj.a(str4, new suk().n("token", str).n("groupId", str2).n("groupName", str3).n("order", Integer.valueOf(i))); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { stc stc = new stc(); stc.czI = SS.getLong("updateTime"); return new ssv<>(a.code, SS, stc); } ssv<stc> ssv = new ssv<>(a.code, SS, null); usj.a(str4, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str4, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<sta> a(String str, String str2, String str3, String str4, String str5, String str6, int i) throws sul { String St = ssn.St(str); if (St == null || St.isEmpty()) { return new ssv<>(-2012, "Network SDK Config Failure"); } String str7 = usE + "/notesvr/set/notecontent"; suk n = new suk().n("token", str).n("noteId", str2).n("thumbnail", str5).n("localContentVersion", Integer.valueOf(i)); try { n.n("title", sua.af(str3, St)); n.n("summary", sua.af(str4, St)); if (!sug.isEmpty(str6) && new File(str6).exists()) { File file = new File(str6); if (file.length() < ((long) usF)) { n.n("bodyType", 0).n("body", sua.af(sug.aT(file), St)); } else { String str8 = file.getAbsolutePath() + ".encrypted"; if (sua.at(St, file.getAbsolutePath(), str8)) { File file2 = new File(str8); stm.fgP(); String str9 = stm.SJ(str).fgN() + str2 + ".encrypted"; n.n("bodyType", 1).n("body", sua.af(str9, St)); sth.b(str, file2, str9); file2.deleteOnExit(); file2.delete(); } } } sum a = suj.a(str7, n); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, sta.e(SS)); } ssv<sta> ssv = new ssv<>(a.code, SS, null); usj.a(str7, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str7, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<ssw> fgK() throws sul { String str = usE + "/notesvr/get/account-ips"; try { sum a = suj.a(str, new suk()); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, ssw.c(SS)); } ssv<ssw> ssv = new ssv<>(a.code, SS, null); usj.a(str, "", ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str, "", th, null); throw new sul(th); } } public static ssv<Void> gd(String str, String str2) throws sul { String str3 = usE + "/notesvr/delete"; try { sum a = suj.a(str3, new suk().n("token", str).n("noteId", str2)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, null); } ssv<Void> ssv = new ssv<>(a.code, SS, null); usj.a(str3, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str3, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<sta> ge(String str, String str2) throws sul { String str3 = usE + "/notesvr/get/contentversion"; try { sum a = suj.a(str3, new suk().n("token", str).n("noteId", str2)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, sta.e(SS)); } ssv<sta> ssv = new ssv<>(a.code, SS, null); usj.a(str3, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str3, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<Void> gf(String str, String str2) throws sul { String str3 = usE + "/notesvr/delete/notegroup"; try { sum a = suj.a(str3, new suk().n("token", str).n("groupId", str2)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, null); } ssv<Void> ssv = new ssv<>(a.code, SS, null); usj.a(str3, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str3, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<ssz> u(String str, Map<String, String> map) throws sul { boolean z; String St = ssn.St(str); if (St == null || St.isEmpty()) { return new ssv<>(-2012, "Network SDK Config Failure"); } String str2 = usE + "/notesvr/get/notebody"; try { sum a = suj.a(str2, new suk().n("token", str).n("noteIds", new ArrayList(map.keySet()))); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { ssz d = ssz.d(SS); for (ssz.a aVar : d.usO) { try { aVar.isW = sua.ag(aVar.isW, St); } catch (Exception e) { aVar.usS = false; } } for (ssz.a aVar2 : d.usO) { if (aVar2.usP != 1 || !aVar2.usS) { String str3 = map.get(aVar2.gDU); File file = new File(str3); if (!file.exists()) { file.createNewFile(); } FileOutputStream fileOutputStream = new FileOutputStream(file); if (aVar2.usS) { fileOutputStream.write(aVar2.isW.getBytes(AudienceNetworkActivity.WEBVIEW_ENCODING)); } else { fileOutputStream.write("[解密失败,请不要编辑该便签,并联系我们解决]".getBytes(AudienceNetworkActivity.WEBVIEW_ENCODING)); } fileOutputStream.close(); aVar2.isW = str3; } else { String str4 = aVar2.gDU; String str5 = map.get(str4); File file2 = new File(str5 + ".encrypted"); if (!file2.exists()) { file2.createNewFile(); } try { sth.a(str, str4, aVar2.isW, file2); z = true; } catch (Exception e2) { e2.printStackTrace(); z = false; } if (z) { try { sua.au(St, file2.getAbsolutePath(), str5); } catch (Exception e3) { aVar2.usS = false; FileOutputStream fileOutputStream2 = new FileOutputStream(str5); fileOutputStream2.write("[解密失败,请不要编辑该便签,并联系我们解决]".getBytes(AudienceNetworkActivity.WEBVIEW_ENCODING)); fileOutputStream2.close(); } } if (file2.exists()) { file2.delete(); } if (!new File(str5).exists()) { new File(str5).createNewFile(); } aVar2.isW = str5; } } return new ssv<>(a.code, SS, d); } ssv<ssz> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<std> x(String str, List<String> list) throws sul { String str2 = usE + "/notesvr/get/noteinfo"; try { sum a = suj.a(str2, new suk().n("token", str).n("noteIds", list)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { return new ssv<>(a.code, SS, std.g(SS)); } ssv<std> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } public static ssv<stf> y(String str, List<String> list) throws sul { String St = ssn.St(str); if (St == null || St.isEmpty()) { return new ssv<>(-2012, "Network SDK Config Failure"); } String str2 = usE + "/notesvr/get/notesummary"; try { sum a = suj.a(str2, new suk().n("token", str).n("noteIds", list)); sup SS = sui.SS(a.bSY); if (a.isSuccessful()) { stf h = stf.h(SS); for (stf.a aVar : h.usZ) { try { aVar.title = sua.ag(aVar.title, St); aVar.summary = sua.ag(aVar.summary, St); } catch (Exception e) { aVar.title = "[解密失败,请不要编辑该便签,并联系我们解决]"; aVar.summary = "[解密失败,请不要编辑该便签,并联系我们解决]"; } } return new ssv<>(a.code, SS, h); } ssv<stf> ssv = new ssv<>(a.code, SS, null); usj.a(str2, ssn.Su(str), ssv.errorCode, ssv.gCV, a); return ssv; } catch (Throwable th) { usj.a(str2, ssn.Su(str), th, null); throw new sul(th); } } }